package com.yunzan.iot_socket.controller;

import com.yunzan.sync_netty.model.Result;
import com.yunzan.sync_netty.server.NettyServer;
import io.netty.handler.codec.http.HttpResponse;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

/**
 * 指令控制
 */
@RestController
@RequestMapping("/command")
public class CommandController {

    @RequestMapping("/send")
    public Result sendCommand(@RequestParam String deviceId,String command,String cmd){
       /* String deviceId="870314001007394";
        String command="[IC*870314001007394*0013*KA]";*/
        String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
        Result re;
        try {
             re=NettyServer.write(command,cmd,deviceId,uuid);
        }catch (Exception e){
            e.printStackTrace();
            return   new Result();
        }
        return  re;
    }
}
